package com.dlyk.controller;

import com.dlyk.result.NameValue;
import com.dlyk.result.R;
import com.dlyk.result.SummaryData;
import com.dlyk.service.StatisticService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
public class StatisticController {

    @Autowired
    private StatisticService statisticService;

    /**
     * 加载概要统计数据
     * @return
     */
    @GetMapping("/api/summary/data")
    public R loadSummary(){
        SummaryData summaryData=statisticService.loadSummary();
        return R.OK(summaryData);
    }


    /**
     * 加载销售漏斗数据
     * @return
     */
    @GetMapping("/api/saleFunnel/data")
    public R loadSaleFunnelChart(){
        List<NameValue> nameValueList=statisticService.loadSaleFunnelChart();
        return R.OK(nameValueList);
    }

    /**
     * 加载线索来源饼状图数据
     * @return
     */
    @GetMapping("/api/resourceClue/data")
    public R loadResourcePieChart(){
        List<NameValue> nameValueList=statisticService.loadResourcePieChart();
        return R.OK(nameValueList);
    }
}
